<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>首页 {$site_info.site_name|default=''}</title>

    <!-- Bootstrap -->
    <link href="__TMPL__/public/assets/cook/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__TMPL__/public/assets/cook/css/toast.css">
    <!--initialize-->
    <link rel="stylesheet" href="__TMPL__/public/assets/cook/css/init.css" />
    <link rel="stylesheet" href="__TMPL__/public/assets/cook/css/index.css">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!---->
<body>
<div class="bj_lj">
    <img src="__TMPL__/public/assets/cook/img/2.png" alt="">
</div>
<div class="mes">
    <div class="user_welcome">
        后勤保障菜品投票系统
    </div>
    <div class="login">
        <form id="form" class="form-horizontal" role="form">
            <div class="form-group">
                <!-- <label for="firstname" class="col-sm-2 control-label">手机号码</label> -->
                <div class="col-sm-10">
                    <input type="number" name="username" class="form-control phone" id="firstname" placeholder="请输入名字">
                </div>
            </div>
            <div class="form-group">
                <!-- <label for="lastname" class="col-sm-2 control-label">验证码</label> -->
                <div class="col-sm-10" style="display:flex;margin-top:0.42rem;">
                    <input type="text" name="captcha" class="form-control" id="lastname" placeholder="请输入验证码">
                    <input type="button" class="form-control yzm" value="获取验证码" name="yzm" style="text-align: center;width:2rem;" disabled="disabled"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" class="btn btn-default gogogo">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="__TMPL__/public/assets/cook/js/jquery-3.2.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="__TMPL__/public/assets/cook/js/bootstrap.min.js"></script>
<script src="__TMPL__/public/assets/cook/js/fontsize.js"></script>
<script src="__TMPL__/public/assets/cook/js/toast.js"></script>
<script>
    $(document).ready(function(){
        var ordertime=60   //设置再次发送验证码等待时间
        var timeleft=ordertime
        var btn=$(".yzm")
        var phone=$(".phone")
        var reg = /^1[0-9]{10}$/;  //电话号码的正则匹配式

        phone.keyup(function(){
            if (reg.test(phone.val())){
                btn.removeAttr("disabled")  //当号码符合规则后发送验证码按钮可点击
            }
            else{
                btn.attr("disabled",true)
            }
        })

        //计时函数
        function timeCount(){
            timeleft-=1
            if (timeleft>0){
                btn.val(timeleft+" 秒后重发");
                setTimeout(timeCount,1000)
            }
            else {
                btn.val("重新发送");
                timeleft=ordertime   //重置等待时间
                btn.removeAttr("disabled");
            }
        }

        //事件处理函数
        btn.on("click",function(){
            $(this).attr("disabled",true); //防止多次点击
            timeCount(this);
            var username=$('#firstname').val();
            $.post("{:url('portal/public/sendVerificationCode')}",{username:username},function (res) {
                showMessage(res.msg,2000,true,'bounceInUp-hastrans','bounceOutDown-hastrans');
            });

        })

        $('.gogogo').on("click",function(){
            $.post("{:url('portal/public/doLogin')}",$('#form').serialize(),function (res) {
                window.location.href=res.url;
            });

        })

    })
</script>
</body>
</html>
